package org.foreningsgatan.genetics;

import java.io.Serializable;

public class MultipleNode<T extends Serializable, S extends Serializable> extends Node<T, S> {
	protected Node<T, S> leftNode;
	protected Node<T, S> rightNode;
	
	protected MultipleNode() {}

	@Override
	protected void perform(SimulationEnvironment<T, S> environment) {
		leftNode.perform(environment);
		rightNode.perform(environment);
	}

	@Override
	protected Node<T, S> clone() {
		MultipleNode<T, S> m = (MultipleNode<T, S>) super.clone();
		
		m.leftNode = leftNode.clone();
		m.rightNode = rightNode.clone();
		
		return m;
	}
	
	@Override
	protected int count() {
		int i = 1;
		
		if (leftNode != null) {
			i += leftNode.count();
		}
		
		if (rightNode != null) {
			i += rightNode.count();
		}
		
		return i;
	}
}
